import request from '@/utils/request'

// 查询客户列表
export function list (query) {
  return request({
    url: '/purchaser/purchaser',
    method: 'get',
    params: query
  })
}

//保存客户关联关系
export function addRelevance (relevanceId, businessCodes) {
  return request({
    url: `/purchaser/purchaser/${relevanceId}/relevance`,
    method: 'post',
    data: businessCodes
  })
}

// 审核客户资质
export function examinePurchaser (purchaserId, body) {
  return request({
    url: `/purchaser/purchaser/${purchaserId}/applyStatus`,
    method: 'put',
    data: body
  })
}

//  获取客户申请资质列表
export function getPurchaserApplyList (purchaserId) {
  return request({
    url: '/purchaser/purchaser/' + purchaserId + '/materials',
    method: 'get',
  })
}

// 审核客户资质
export function examinePurchaserImg (purchaserId, purchaserMaterialId, val) {
  return request({
    url: `/purchaser/purchaser/${purchaserId}/materials/${purchaserMaterialId}/applyStatus`,
    method: 'put',
    data: val
  })
}

// /purchaser/purchaser/{purchaserId}/certifiedMaterials  获取客户ERP同步资质列表
export function getPurchaserImgLabel (purchaserId) {
  return request({
    url: `/purchaser/purchaser/${purchaserId}/certifiedMaterials`,
    method: 'get',
  })
}

// 修改客户经营范围
export function updateBusiness (purchaserId, val) {
  return request({
    url: `/purchaser/purchaser/${purchaserId}/business`,
    method: 'put',
    data: val
  })
}


// 修改密码
export function changePassword (purchaserId, memberId, data) {
  return request({
    url: `/purchaser/purchaser/${purchaserId}/members/${memberId}/password`,
    method: 'put',
    data: data
  })
}
// 修改账号
export function changeAccount (purchaserId, data) {
  return request({
    url: `/purchaser/purchaser/${purchaserId}/members/username`,
    method: 'put',
    data: data
  })
}
// 修改手机号
export function changePhone (purchaserId, memberId, data) {
  return request({
    url: `/purchaser/purchaser/${purchaserId}/members/${memberId}/password`,
    method: 'put',
    data: data
  })
}
// 一键审核客户资质
export function autoExamine (purchaserId, data) {
  return request({
    url: `/purchaser/purchaser/${purchaserId}/materials/applyStatus`,
    method: 'put',
    data: data
  })
}


// 删除 客户资质 行
export function deletePurchaserQualifications (purchaserId) {
  return request({
    url: `/purchaser/purchaser/${purchaserId}`,
    method: 'delete',
  })
}

//删除ERP同步的资质
export function deletePurchasercertifiedMaterial (purchaserId, certifiedMaterialId) {
  return request({
    url: `/purchaser/purchaser/${purchaserId}/materials/${certifiedMaterialId}`,
    method: 'delete',
  })
}


// 查询客户收货地址列表
export function getAddressList (query) {
  return request({
    url: '/purchaser/address',
    method: 'get',
    params: query
  })
}
